import { makeAutoObservable } from 'mobx'
import { setCookie, removeCookie } from '@/utils/auth'
import { getCaptrue, getLogin, teacherBlanList, teacherLogin } from '@/services'
import { inteLoginItem, intecaptrueImage} from '@/utils/interface'
class Login{
    constructor(){
        makeAutoObservable(this)
    }
    getcaptrueImage:intecaptrueImage ={} as intecaptrueImage;
    authorization:string = '';
    // getteacherlogin:any = {}
    // teacherblanlist:any = []
    async getCaptrue(){
        let result = await getCaptrue();
        if(result.code == 200){
            let {img, uuid } = result;
            this.getcaptrueImage = {img, uuid};
        }
    }
    async getLogin(data:inteLoginItem){
        let result = await getLogin({...data,uuid:this.getcaptrueImage.uuid})
        if(result.code == 200){
            let authorization = this.authorization = `Bearer ${result.token}`;
            setCookie(authorization);
            return authorization
        }
    }
    logout(){
        removeCookie();
        this.authorization = '';
    } 
}
export default new Login